American Standard Code for Information Interchange (ASCII) to binary floating point format conversion of decimal real numbers is a common task for applications such as financial-services-trading data processing. Commodity microprocessors tackle this problem by iterating over the individual digits of the real number and accumulate the partial result until a decimal point delimiter character or a string delimiter character is found, which ends the process. Because numbers, when expressed in ASCII format, can assume arbitrary length, the traditional algorithms solve the problem in a time directly proportional to the length of the string representing the number, and the generated code contains several branches, which can cause severe latency penalties on several modern processing architectures.
Methods for conversion of a real number from ASCII to binary floating point within a processor are known. These methods include identifying the beginning, ending, sign, and decimal point position of the real number in the ASCII string, extracting the decimal point, followed by taking each of the seven bit components of the ASCII real number, one character at a time, and subtracting the binary number, forty eight, to get the decimal numbers that make up the real number. Then, each of the decimal components of the real number is multiplied by a power of ten, starting with ten to the zero power, or one, for the least significant digit, ten to the first power, or ten, for the digit to the left of the least significant digit, if applicable, ten to the second power, or one hundred, for the digit to the left of the previous digit, if applicable, etc. This is repeated for as many digits comprising the real number, up to and including the most significant digit. Each of these products is then accumulated and the sign added, resulting in a binary decimal converted number. To process this number into a floating point format, the position, identified above, for the decimal point is shifted to the left until only one non-zero digit remains to the left of the decimal point position. This is called normalization. Corresponding to this shift, the number of shifted positions is noted so that the resulting number of one non-zero digit followed by the decimal point, followed by the fraction may be multiplied by the radix raised to the power of the number of decimal point shifts. The final floating point representation is the sign, the real number or the mantissa, and the fraction, or exponent.
One problem with this technique is that, since it is iterative, the time for conversion will vary, becoming longer as the size of the ASCII real number string increases. Another problem is that code for performing the conversion function involves branching and the use of multiple instructions, also adding to the execution time and efficiency of the conversion, due to latency issues.